Skip to content

release: merge dev into main#21

Merged
danieldiazde merged 3 commits into
mainfrom
dev
May 9, 2026
Merged

release: merge dev into main#21
danieldiazde merged 3 commits into
mainfrom
dev

Conversation

@danieldiazde
Copy link
Copy Markdown
Owner

Summary

  • Merge latest TecCoach dashboard polish from dev into main
  • Includes PDF horario parser work and dashboard auto-sync/auto-generate fixes

Verification

danieldiazde and others added 3 commits May 9, 2026 14:59
Replaces the hand-rolled "5+1+5+1+5" Tec21 calendar with the real periods
extracted from the student's official MiTec horario PDF. Periods, materias,
CRNs, schedules, and Semana Tec flags now come from the source of truth
instead of being computed from a single start date.

Backend
- lib/pdf/horario-parser.ts: sends the PDF directly to Gemini multimodal
  (gemini-2.5-flash) with a structured response schema. Returns alumno,
  matricula, periodo, and an array of materias with their `periodos`
  (each with inicio/fin/dias/hora_inicio/hora_fin/ubicacion/es_semana_tec).
- POST /api/profile/horario: multipart upload, parses, replaces
  materias_inscritas with PDF-derived rows and updates profiles with
  periodo_nombre/periodo_inicio/periodo_fin.
- lib/tec21/calendar.ts refactor: getPeriodoActivo() reads materias_inscritas.periodos
  to detect Semana Tec (any active period flagged) or compute the current
  block boundaries (intersection of active non-tec periods). Returns a
  human label and dias_restantes_bloque for prompt context.
- lib/gemini/prompts.ts: prompt now uses periodo_activo (real data) instead
  of computed semana_actual; new rules around Semana Tec; stronger Canvas
  prioritization; few-shot updated to a Semana Tec scenario.
- /api/insights/generate: filters materias to those active in the current
  period, marks Semana Tec materias, keeps Canvas-inferred materias.

Frontend
- OnboardingFlow rewritten: paso 3 ahora es "sube tu PDF de MiTec" en lugar
  de selección manual de materias. Auto-fills nombre/matricula del PDF.
- Old SelectedMateria/TOGGLE_MATERIA logic removed — PDF is source of truth.

Schema
- profiles.semestre_inicio dropped; replaced by periodo_nombre/periodo_inicio/periodo_fin.
- materias_inscritas: + crn text, + periodos jsonb.

Migration:
  ALTER TABLE profiles DROP COLUMN IF EXISTS semestre_inicio;
  ALTER TABLE profiles ADD COLUMN IF NOT EXISTS periodo_nombre text;
  ALTER TABLE profiles ADD COLUMN IF NOT EXISTS periodo_inicio date;
  ALTER TABLE profiles ADD COLUMN IF NOT EXISTS periodo_fin date;
  ALTER TABLE materias_inscritas ADD COLUMN IF NOT EXISTS crn text;
  ALTER TABLE materias_inscritas ADD COLUMN IF NOT EXISTS periodos jsonb default '[]'::jsonb;

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat: PDF horario upload — real Tec21 calendar from MiTec
…#20)

* fix: dashboard always shows current week + surface Google Calendar errors

Two bugs reported on demo:

1. Dashboard header showed stale week (e.g. "27 de abril al 3 de mayo" while
   today is May 9). Cause: dashboard anchored the week to insight.semana_iso,
   so a cached insight from a previous ISO week dragged the UI back. Fix:
   always anchor to today; if the cached insight is from a different ISO week,
   treat as no-insight and render EmptyInsightCard so the user regenerates.

2. /api/calendar/create returned a generic "No se pudo crear ningún evento"
   that hid the real Google API error. Cause: createEvents only logged errors
   to the server. Fix: return per-event errors with status + message in the
   response. Also adds timeZone: "America/Monterrey" to start/end (Google
   rejects ambiguous datetimes without offset). When the first error is
   401/403 the response includes a "cierra sesión y vuelve a entrar" hint
   so the user can refresh the OAuth token if scope is the issue.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: better error messages when Google Calendar API is disabled

- Bump error message truncation from 200 to 500 chars so the full Cloud
  Console URL Google returns isn't cut off mid-word.
- New hint logic: if the response mentions "has not been used" or "disabled"
  we tell the user to enable the API instead of pointing them to re-login.
  The previous re-login hint only made sense for actual auth failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(dashboard): auto-sync Google Calendar + Canvas iCal on every load

The dashboard reads `eventos` from the DB but nothing was populating that
table on its own — the user had to manually POST to /api/calendar/sync or
/api/canvas/sync to see anything. Now we sync both right before rendering
so a fresh login or page reload shows real events without any extra step.

- lib/google/calendar.ts: extract syncGoogleCalendarToDb(supabase, userId)
  reusable from server components, so the dashboard and the existing route
  share one implementation.
- lib/ical/parser.ts: same — syncCanvasIcalToDb(supabase, userId, icalUrl)
  reads profile.canvas_ical_url and upserts entregas.
- dashboard/page.tsx: autoSyncExternalCalendars() runs both syncs in
  parallel via Promise.allSettled before loadCurrentInsight + loadWeekEventos,
  swallowing per-source errors so a stale cache is preferred over a broken
  dashboard. Skipped in demo mode (?demo=1).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(dashboard): auto-generate weekly insight on empty state

When the dashboard lands on EmptyInsightCard the user had to click "Generar
mi semana" to get any blocks. Now the card auto-fires the generation on
first mount (using useRef guard so React strict-mode double-render doesn't
double-trigger). Loading title + spinner reflect the in-flight call. If
generation errors, surface the server's error message inline and switch
the button to "Reintentar" without auto-retrying.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@supabase
Copy link
Copy Markdown

supabase Bot commented May 9, 2026

This pull request has been ignored for the connected project jwqffychkaczvknfgzbd because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@danieldiazde danieldiazde merged commit 30ba152 into main May 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant